{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pandas import Series, DataFrame"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Beyond 1\n",
    "\n",
    "Ignore the `password` and `groupid` fields, such that they don't appear in the data frame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>username</th>\n",
       "      <th>userid</th>\n",
       "      <th>name</th>\n",
       "      <th>homedir</th>\n",
       "      <th>shell</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>root</td>\n",
       "      <td>0</td>\n",
       "      <td>root</td>\n",
       "      <td>/root</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>daemon</td>\n",
       "      <td>1</td>\n",
       "      <td>daemon</td>\n",
       "      <td>/usr/sbin</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>bin</td>\n",
       "      <td>2</td>\n",
       "      <td>bin</td>\n",
       "      <td>/bin</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>sys</td>\n",
       "      <td>3</td>\n",
       "      <td>sys</td>\n",
       "      <td>/dev</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>sync</td>\n",
       "      <td>4</td>\n",
       "      <td>sync</td>\n",
       "      <td>/bin</td>\n",
       "      <td>/bin/sync</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>games</td>\n",
       "      <td>5</td>\n",
       "      <td>games</td>\n",
       "      <td>/usr/games</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>man</td>\n",
       "      <td>6</td>\n",
       "      <td>man</td>\n",
       "      <td>/var/cache/man</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>lp</td>\n",
       "      <td>7</td>\n",
       "      <td>lp</td>\n",
       "      <td>/var/spool/lpd</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>mail</td>\n",
       "      <td>8</td>\n",
       "      <td>mail</td>\n",
       "      <td>/var/mail</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>news</td>\n",
       "      <td>9</td>\n",
       "      <td>news</td>\n",
       "      <td>/var/spool/news</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>uucp</td>\n",
       "      <td>10</td>\n",
       "      <td>uucp</td>\n",
       "      <td>/var/spool/uucp</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>proxy</td>\n",
       "      <td>13</td>\n",
       "      <td>proxy</td>\n",
       "      <td>/bin</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>www-data</td>\n",
       "      <td>33</td>\n",
       "      <td>www-data</td>\n",
       "      <td>/var/www</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>backup</td>\n",
       "      <td>34</td>\n",
       "      <td>backup</td>\n",
       "      <td>/var/backups</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>list</td>\n",
       "      <td>38</td>\n",
       "      <td>Mailing List Manager</td>\n",
       "      <td>/var/list</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>irc</td>\n",
       "      <td>39</td>\n",
       "      <td>ircd</td>\n",
       "      <td>/var/run/ircd</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>gnats</td>\n",
       "      <td>41</td>\n",
       "      <td>Gnats Bug-Reporting System (admin)</td>\n",
       "      <td>/var/lib/gnats</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>nobody</td>\n",
       "      <td>65534</td>\n",
       "      <td>nobody</td>\n",
       "      <td>/nonexistent</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>syslog</td>\n",
       "      <td>101</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/home/syslog</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>messagebus</td>\n",
       "      <td>102</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/run/dbus</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>landscape</td>\n",
       "      <td>103</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/lib/landscape</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>jci</td>\n",
       "      <td>955</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/home/jci</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>sshd</td>\n",
       "      <td>104</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/run/sshd</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>user</td>\n",
       "      <td>1000</td>\n",
       "      <td>user,,,</td>\n",
       "      <td>/home/user</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>reuven</td>\n",
       "      <td>1001</td>\n",
       "      <td>Reuven M. Lerner,,,</td>\n",
       "      <td>/home/reuven</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>postfix</td>\n",
       "      <td>105</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/spool/postfix</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>colord</td>\n",
       "      <td>106</td>\n",
       "      <td>colord colour management daemon,,,</td>\n",
       "      <td>/var/lib/colord</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>postgres</td>\n",
       "      <td>107</td>\n",
       "      <td>PostgreSQL administrator,,,</td>\n",
       "      <td>/var/lib/postgresql</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>dovecot</td>\n",
       "      <td>108</td>\n",
       "      <td>Dovecot mail server,,,</td>\n",
       "      <td>/usr/lib/dovecot</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>dovenull</td>\n",
       "      <td>109</td>\n",
       "      <td>Dovecot login user,,,</td>\n",
       "      <td>/nonexistent</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>postgrey</td>\n",
       "      <td>110</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/lib/postgrey</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>debian-spamd</td>\n",
       "      <td>111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/lib/spamassassin</td>\n",
       "      <td>/bin/sh</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>memcache</td>\n",
       "      <td>113</td>\n",
       "      <td>Memcached,,,</td>\n",
       "      <td>/nonexistent</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>genadi</td>\n",
       "      <td>1002</td>\n",
       "      <td>Genadi Reznichenko,,,</td>\n",
       "      <td>/home/genadi</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>shira</td>\n",
       "      <td>1003</td>\n",
       "      <td>Shira Friedman,,,</td>\n",
       "      <td>/home/shira</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>atara</td>\n",
       "      <td>1004</td>\n",
       "      <td>Atara Lerner-Friedman,,,</td>\n",
       "      <td>/home/atara</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>shikma</td>\n",
       "      <td>1005</td>\n",
       "      <td>Shikma Lerner-Friedman,,,</td>\n",
       "      <td>/home/shikma</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>amotz</td>\n",
       "      <td>1006</td>\n",
       "      <td>Amotz Lerner-Friedman,,,</td>\n",
       "      <td>/home/amotz</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>mysql</td>\n",
       "      <td>114</td>\n",
       "      <td>MySQL Server,,,</td>\n",
       "      <td>/nonexistent</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>clamav</td>\n",
       "      <td>115</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/lib/clamav</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>amavis</td>\n",
       "      <td>116</td>\n",
       "      <td>AMaViS system user,,,</td>\n",
       "      <td>/var/lib/amavis</td>\n",
       "      <td>/bin/sh</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>opendkim</td>\n",
       "      <td>117</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/run/opendkim</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>gitlab-redis</td>\n",
       "      <td>999</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/opt/gitlab/redis</td>\n",
       "      <td>/bin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>gitlab-psql</td>\n",
       "      <td>998</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/opt/gitlab/postgresql</td>\n",
       "      <td>/bin/sh</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>git</td>\n",
       "      <td>1007</td>\n",
       "      <td>GitLab,,,</td>\n",
       "      <td>/home/git</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>opendmarc</td>\n",
       "      <td>118</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/run/opendmarc</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>dkim-milter-python</td>\n",
       "      <td>119</td>\n",
       "      <td>NaN</td>\n",
       "      <td>/var/run/dkim-milter-python</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>deploy</td>\n",
       "      <td>1008</td>\n",
       "      <td>Deploy,,,</td>\n",
       "      <td>/home/deploy</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>redis</td>\n",
       "      <td>112</td>\n",
       "      <td>redis server,,,</td>\n",
       "      <td>/var/lib/redis</td>\n",
       "      <td>/bin/false</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              username  userid                                name  \\\n",
       "0                 root       0                                root   \n",
       "1               daemon       1                              daemon   \n",
       "2                  bin       2                                 bin   \n",
       "3                  sys       3                                 sys   \n",
       "4                 sync       4                                sync   \n",
       "5                games       5                               games   \n",
       "6                  man       6                                 man   \n",
       "7                   lp       7                                  lp   \n",
       "8                 mail       8                                mail   \n",
       "9                 news       9                                news   \n",
       "10                uucp      10                                uucp   \n",
       "11               proxy      13                               proxy   \n",
       "12            www-data      33                            www-data   \n",
       "13              backup      34                              backup   \n",
       "14                list      38                Mailing List Manager   \n",
       "15                 irc      39                                ircd   \n",
       "16               gnats      41  Gnats Bug-Reporting System (admin)   \n",
       "17              nobody   65534                              nobody   \n",
       "18              syslog     101                                 NaN   \n",
       "19          messagebus     102                                 NaN   \n",
       "20           landscape     103                                 NaN   \n",
       "21                 jci     955                                 NaN   \n",
       "22                sshd     104                                 NaN   \n",
       "23                user    1000                             user,,,   \n",
       "24              reuven    1001                 Reuven M. Lerner,,,   \n",
       "25             postfix     105                                 NaN   \n",
       "26              colord     106  colord colour management daemon,,,   \n",
       "27            postgres     107         PostgreSQL administrator,,,   \n",
       "28             dovecot     108              Dovecot mail server,,,   \n",
       "29            dovenull     109               Dovecot login user,,,   \n",
       "30            postgrey     110                                 NaN   \n",
       "31        debian-spamd     111                                 NaN   \n",
       "32            memcache     113                        Memcached,,,   \n",
       "33              genadi    1002               Genadi Reznichenko,,,   \n",
       "34               shira    1003                   Shira Friedman,,,   \n",
       "35               atara    1004            Atara Lerner-Friedman,,,   \n",
       "36              shikma    1005           Shikma Lerner-Friedman,,,   \n",
       "37               amotz    1006            Amotz Lerner-Friedman,,,   \n",
       "38               mysql     114                     MySQL Server,,,   \n",
       "39              clamav     115                                 NaN   \n",
       "40              amavis     116               AMaViS system user,,,   \n",
       "41            opendkim     117                                 NaN   \n",
       "42        gitlab-redis     999                                 NaN   \n",
       "43         gitlab-psql     998                                 NaN   \n",
       "44                 git    1007                           GitLab,,,   \n",
       "45           opendmarc     118                                 NaN   \n",
       "46  dkim-milter-python     119                                 NaN   \n",
       "47              deploy    1008                           Deploy,,,   \n",
       "48               redis     112                     redis server,,,   \n",
       "\n",
       "                        homedir              shell  \n",
       "0                         /root          /bin/bash  \n",
       "1                     /usr/sbin  /usr/sbin/nologin  \n",
       "2                          /bin  /usr/sbin/nologin  \n",
       "3                          /dev  /usr/sbin/nologin  \n",
       "4                          /bin          /bin/sync  \n",
       "5                    /usr/games  /usr/sbin/nologin  \n",
       "6                /var/cache/man  /usr/sbin/nologin  \n",
       "7                /var/spool/lpd  /usr/sbin/nologin  \n",
       "8                     /var/mail  /usr/sbin/nologin  \n",
       "9               /var/spool/news  /usr/sbin/nologin  \n",
       "10              /var/spool/uucp  /usr/sbin/nologin  \n",
       "11                         /bin  /usr/sbin/nologin  \n",
       "12                     /var/www  /usr/sbin/nologin  \n",
       "13                 /var/backups  /usr/sbin/nologin  \n",
       "14                    /var/list  /usr/sbin/nologin  \n",
       "15                /var/run/ircd  /usr/sbin/nologin  \n",
       "16               /var/lib/gnats  /usr/sbin/nologin  \n",
       "17                 /nonexistent  /usr/sbin/nologin  \n",
       "18                 /home/syslog         /bin/false  \n",
       "19                /var/run/dbus         /bin/false  \n",
       "20           /var/lib/landscape         /bin/false  \n",
       "21                    /home/jci          /bin/bash  \n",
       "22                /var/run/sshd  /usr/sbin/nologin  \n",
       "23                   /home/user          /bin/bash  \n",
       "24                 /home/reuven          /bin/bash  \n",
       "25           /var/spool/postfix         /bin/false  \n",
       "26              /var/lib/colord         /bin/false  \n",
       "27          /var/lib/postgresql          /bin/bash  \n",
       "28             /usr/lib/dovecot         /bin/false  \n",
       "29                 /nonexistent         /bin/false  \n",
       "30            /var/lib/postgrey         /bin/false  \n",
       "31        /var/lib/spamassassin            /bin/sh  \n",
       "32                 /nonexistent         /bin/false  \n",
       "33                 /home/genadi          /bin/bash  \n",
       "34                  /home/shira          /bin/bash  \n",
       "35                  /home/atara          /bin/bash  \n",
       "36                 /home/shikma          /bin/bash  \n",
       "37                  /home/amotz          /bin/bash  \n",
       "38                 /nonexistent         /bin/false  \n",
       "39              /var/lib/clamav         /bin/false  \n",
       "40              /var/lib/amavis            /bin/sh  \n",
       "41            /var/run/opendkim         /bin/false  \n",
       "42        /var/opt/gitlab/redis       /bin/nologin  \n",
       "43   /var/opt/gitlab/postgresql            /bin/sh  \n",
       "44                    /home/git          /bin/bash  \n",
       "45           /var/run/opendmarc         /bin/false  \n",
       "46  /var/run/dkim-milter-python         /bin/false  \n",
       "47                 /home/deploy          /bin/bash  \n",
       "48               /var/lib/redis         /bin/false  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Note that we name all columns, and then only use a subset of them\n",
    "df = pd.read_csv('../data/linux-etc-passwd.txt', \n",
    "                 sep=':', comment='#', header=None,\n",
    "                 usecols=['username', 'userid', 'name', 'homedir', 'shell'],\n",
    "                names=['username', 'password', 'userid', 'groupid', 'name', 'homedir', 'shell'])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Beyond 2\n",
    "\n",
    "Unix systems typically reserve user IDs below 1000 to special accounts.  Show the non-special usernames in this `passwd` file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>username</th>\n",
       "      <th>password</th>\n",
       "      <th>userid</th>\n",
       "      <th>groupid</th>\n",
       "      <th>name</th>\n",
       "      <th>homedir</th>\n",
       "      <th>shell</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>nobody</td>\n",
       "      <td>x</td>\n",
       "      <td>65534</td>\n",
       "      <td>65534</td>\n",
       "      <td>nobody</td>\n",
       "      <td>/nonexistent</td>\n",
       "      <td>/usr/sbin/nologin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>user</td>\n",
       "      <td>x</td>\n",
       "      <td>1000</td>\n",
       "      <td>1000</td>\n",
       "      <td>user,,,</td>\n",
       "      <td>/home/user</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>reuven</td>\n",
       "      <td>x</td>\n",
       "      <td>1001</td>\n",
       "      <td>1001</td>\n",
       "      <td>Reuven M. Lerner,,,</td>\n",
       "      <td>/home/reuven</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>genadi</td>\n",
       "      <td>x</td>\n",
       "      <td>1002</td>\n",
       "      <td>1003</td>\n",
       "      <td>Genadi Reznichenko,,,</td>\n",
       "      <td>/home/genadi</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>shira</td>\n",
       "      <td>x</td>\n",
       "      <td>1003</td>\n",
       "      <td>1004</td>\n",
       "      <td>Shira Friedman,,,</td>\n",
       "      <td>/home/shira</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>atara</td>\n",
       "      <td>x</td>\n",
       "      <td>1004</td>\n",
       "      <td>1005</td>\n",
       "      <td>Atara Lerner-Friedman,,,</td>\n",
       "      <td>/home/atara</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>shikma</td>\n",
       "      <td>x</td>\n",
       "      <td>1005</td>\n",
       "      <td>1006</td>\n",
       "      <td>Shikma Lerner-Friedman,,,</td>\n",
       "      <td>/home/shikma</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>amotz</td>\n",
       "      <td>x</td>\n",
       "      <td>1006</td>\n",
       "      <td>1007</td>\n",
       "      <td>Amotz Lerner-Friedman,,,</td>\n",
       "      <td>/home/amotz</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>git</td>\n",
       "      <td>x</td>\n",
       "      <td>1007</td>\n",
       "      <td>1008</td>\n",
       "      <td>GitLab,,,</td>\n",
       "      <td>/home/git</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>deploy</td>\n",
       "      <td>x</td>\n",
       "      <td>1008</td>\n",
       "      <td>1011</td>\n",
       "      <td>Deploy,,,</td>\n",
       "      <td>/home/deploy</td>\n",
       "      <td>/bin/bash</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   username password  userid  groupid                       name  \\\n",
       "17   nobody        x   65534    65534                     nobody   \n",
       "23     user        x    1000     1000                    user,,,   \n",
       "24   reuven        x    1001     1001        Reuven M. Lerner,,,   \n",
       "33   genadi        x    1002     1003      Genadi Reznichenko,,,   \n",
       "34    shira        x    1003     1004          Shira Friedman,,,   \n",
       "35    atara        x    1004     1005   Atara Lerner-Friedman,,,   \n",
       "36   shikma        x    1005     1006  Shikma Lerner-Friedman,,,   \n",
       "37    amotz        x    1006     1007   Amotz Lerner-Friedman,,,   \n",
       "44      git        x    1007     1008                  GitLab,,,   \n",
       "47   deploy        x    1008     1011                  Deploy,,,   \n",
       "\n",
       "         homedir              shell  \n",
       "17  /nonexistent  /usr/sbin/nologin  \n",
       "23    /home/user          /bin/bash  \n",
       "24  /home/reuven          /bin/bash  \n",
       "33  /home/genadi          /bin/bash  \n",
       "34   /home/shira          /bin/bash  \n",
       "35   /home/atara          /bin/bash  \n",
       "36  /home/shikma          /bin/bash  \n",
       "37   /home/amotz          /bin/bash  \n",
       "44     /home/git          /bin/bash  \n",
       "47  /home/deploy          /bin/bash  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('../data/linux-etc-passwd.txt',\n",
    "                 sep=':', comment='#', header=None,\n",
    "                names=['username', 'password', 'userid', 'groupid', 'name', 'homedir', 'shell'])\n",
    "\n",
    "df[df['userid'] >= 1000]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Beyond 3\n",
    "\n",
    "Immediately after logging into a Unix system, a command interpreter, known as a \"shell,\" fires up. What are the different shells in this file?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0             /bin/bash\n",
       "1     /usr/sbin/nologin\n",
       "4             /bin/sync\n",
       "18           /bin/false\n",
       "31              /bin/sh\n",
       "42         /bin/nologin\n",
       "Name: shell, dtype: object"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# The `unique` method does this for us, returning a NumPy array -- but Pandas offers its own\n",
    "# drop_duplicates method, which keeps us with a series\n",
    "\n",
    "df['shell'].drop_duplicates()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
